jQuery( window ).load( function() {
try {
var og_title = encodeURIComponent( document.querySelector( "meta[property='og:title']" ).getAttribute( "content" ) );
var og_url = document.querySelector( "meta[property='og:url']" ).getAttribute( "content" );
var ssurl = jQuery('#nextButton').data('href');
} catch( err ) {}
var shareStart_part1 = '
- Share
';
shareStart_part2 = ' ';
shareStart_part3 = '
';
shareStart = shareStart_part1 + shareStart_part2 + shareStart_part3;
if( ssurl!='' && typeof ( ssurl ) != 'undefined' ) {
if( navigator.userAgent.toLowerCase().match('mobile') ) {
try{
var shareNex = '';
} catch(errr){}
} else {
var shareNex = '';
}
} else {
var shareNex = '';
}
var share_button = shareStart + shareNex;
jQuery( '.append_social_share' ).html( share_button );
var show_fb_count = 0;
if( 1 === show_fb_count && '' !== s_post_id && 'undefined' !== s_post_id ) {
var post_id = parseInt( s_post_id );
try {
jQuery.ajax({
url: "https://graph.facebook.com?id="+og_url+"&fields=og_object{engagement}",
type:"get",
dataType: "jsonp",
cache: true
}).done( function( value ) {
if( value['og_object'] != undefined && value['og_object'] != null ){
jQuery.ajax({
url: "/share-count/" + post_id + '/'+parseInt( value['og_object']['engagement']['count'] )+'/update/',
cache: true
}).done(function( countdata ) {
jQuery( "#sharecount" ).html( nFormatter( countdata ) );
});
} else {
jQuery.ajax({
url: "/share-count/" + post_id + '/getvalue',
cache: true
}).done(function( countdata ) {
jQuery( "#sharecount" ).html( nFormatter( countdata ) );
});
}
}).fail( function() {
jQuery.ajax({
url: "/share-count/" + post_id + '/getvalue',
cache: true
}).done(function( countdata ) {
jQuery( "#sharecount" ).html( nFormatter( countdata ) );
});
});
} catch( err ){}
}
});
function nFormatter( num ) {
if ( num >= 1000000000 ) {
return (num / 1000000000).toFixed( 1 ).replace( /\.0$/, '' ) + 'G';
}
if ( num >= 1000000 ) {
return ( num / 1000000 ).toFixed( 1 ).replace( /\.0$/, '' ) + 'M';
}
if ( num >= 1000 ) {
return ( num / 1000 ).toFixed( 1 ).replace( /\.0$/, '' ) + 'K';
}
return num;
}